
<%@ page import="org.codehaus.groovy.grails.commons.ConfigurationHolder"%>
<%@ page import="vendingmachine.PaymentTransaction"%>
<!doctype html>
<html>
<head>
<meta name="layout" content="main">
<g:set var="entityName"
	value="${message(code: 'paymentTransaction.label', default: 'PaymentTransaction')}" />
<title><g:message code="default.list.label" args="[entityName]" />
</title>
	
</head>
<body>

<div id="fb-root"></div>
<script type="text/javascript">
	window.fbAsyncInit = function() {
	    FB.init({
	      appId      : '${ConfigurationHolder.config.grails.facebooAppID}', // App ID
	  //    channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
	      status     : true, // check login status
	      cookie     : true, // enable cookies to allow the server to access the session
	      xfbml      : true  // parse XFBML
	    });

	    FB.Event.subscribe('auth.authResponseChange', function(response) {
		      alert('response.status = '+ response.status);
	    	  if (response.status == 'connected') {
			  } else if (response.status == 'not_authorized') {
				  window.location = "/vendingMachine/userProcess/register";
			  } else {
				  window.location = "/vendingMachine/information/login";
			  }
	    });
	    
	     FB.getLoginStatus(function(response) {
	    	if (response.status == 'connected') {
	    		//var uid = response.authResponse.userID;
			    //var accessToken = response.authResponse.accessToken;
			    //window.location = "main?uid=" + uid + "&token=" + accessToken;
			} else if (response.status == 'not_authorized') {
				window.location = "/vendingMachine/userProcess/register";
			  } else {
				//window.location = "/vendingMachine/information/login";
				  window.location =  "http://apps.facebook.com/ia_vending_machine/";
		      }
	    });
	};
     (function(d){
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     ref.parentNode.insertBefore(js, ref);
   }(document));
	</script>
<div id="list-match" class="content scaffold-list" role="main">
		<img src="${resource(dir: 'images', file: 'banner.png')}"/>
		<g:if test="${user}">Hello ${user.username}!! [logout]</g:if>
			<table>
				<thead>
					<tr>
						<g:sortableColumn property="cardId" title="${message(code: 'match.cardId.label', default: 'Card Id')}" />
					
						<th><g:message code="match.coupon.label" default="Coupon" /></th>
					
						<th><g:message code="match.state.label" default="State" /></th>
					</tr>
				</thead>
				<tbody>
				<g:each in="${matchInstanceList}" status="i" var="matchInstance">
					<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
					
						<td><g:link action="showCoupon" id="${matchInstance.id}">${fieldValue(bean: matchInstance, field: "cardId")}</g:link></td>
					
						<td>${fieldValue(bean: matchInstance, field: "coupon")}</td>
					
						<td>${fieldValue(bean: matchInstance, field: "state")}</td>

					</tr>
				</g:each>
				</tbody>
			</table>
		</div>
</body>
</html>
